<?php
/**
 * Dependency show interface action
 *
 * PHP version 5
 *
 * @category  W
 * @package   Services
 * @author    Olivier Hoareau <olivier@phppro.fr>
 * @copyright 2009 PHPPRO http://www.phppro.fr
 * @license   http://dev.phppro.fr/license PHPPRO
 * @version   SVN: $Id:$
 * @link      http://dev.phppro.fr/projects/wdependency
 */
require_once 'W/Dependency/Action/Abstract.php';
require_once 'W/W.php';
require_once 'W/Dependency/Exception/Stop.php';
/**
 * Dependency show interface action
 *
 * @category  W
 * @package   Services
 * @author    Olivier Hoareau <olivier@phppro.fr>
 * @copyright 2009 PHPPRO http://www.phppro.fr
 * @license   http://dev.phppro.fr/license PHPPRO
 * @version   SVN: $Id$
 * @link      http://dev.phppro.fr/projects/wdependency
 */
class W_Dependency_Action_ShowInterface extends W_Dependency_Action_Abstract
{
    private $class;

    public function setClass($class)
    {
        $this->class = $class;
        return $this;
    }
    /**
     * Process the action
     *
     * @param array|null $options the options
     *
     * @throws W_Dependency_Exception_Stop if stop
     */
    public function execute($options=null)
    {
        if (null === $this->class) {
            throw new RuntimeException("No class/interface provided");
        }
        $file = dirname(__FILE__).'/../../../'.str_replace('_','/',$this->class).'/Interface.php';
        if (false === W_W::fs()->isExistingFile($file)) {
            throw new RuntimeException("Class/interface file '$file' does not exist");
        }
        echo file_get_contents($file);
        throw new W_Dependency_Exception_Stop();
    }
}